﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.adobe.net {

    public class URI {

        protected var _valid:Boolean;// = false
        protected var _relative:Boolean;// = false
        protected var _scheme:String;// = ""
        protected var _authority:String;// = ""
        protected var _username:String;// = ""
        protected var _password:String;// = ""
        protected var _port:String;// = ""
        protected var _path:String;// = ""
        protected var _query:String;// = ""
        protected var _fragment:String;// = ""
        protected var _nonHierarchical:String;// = ""

        public static const URImustEscape:String = " %";
        public static const URIbaselineEscape:String = (URImustEscape + ":?#/@");
        public static const URIpathEscape:String = (URImustEscape + "?#");
        public static const URIqueryEscape:String = (URImustEscape + "#");
        public static const URIqueryPartEscape:String = (URImustEscape + "#&=");
        public static const URInonHierEscape:String = (URImustEscape + "?#/");
        public static const UNKNOWN_SCHEME:String = "unknown";
        protected static const URIbaselineExcludedBitmap:URIEncodingBitmap = new URIEncodingBitmap(URIbaselineEscape);
        protected static const URIschemeExcludedBitmap:URIEncodingBitmap = URIbaselineExcludedBitmap;
        protected static const URIuserpassExcludedBitmap:URIEncodingBitmap = URIbaselineExcludedBitmap;
        protected static const URIauthorityExcludedBitmap:URIEncodingBitmap = URIbaselineExcludedBitmap;
        protected static const URIportExludedBitmap:URIEncodingBitmap = URIbaselineExcludedBitmap;
        protected static const URIpathExcludedBitmap:URIEncodingBitmap = new URIEncodingBitmap(URIpathEscape);
        protected static const URIqueryExcludedBitmap:URIEncodingBitmap = new URIEncodingBitmap(URIqueryEscape);
        protected static const URIqueryPartExcludedBitmap:URIEncodingBitmap = new URIEncodingBitmap(URIqueryPartEscape);
        protected static const URIfragmentExcludedBitmap:URIEncodingBitmap = URIqueryExcludedBitmap;
        protected static const URInonHierexcludedBitmap:URIEncodingBitmap = new URIEncodingBitmap(URInonHierEscape);
        public static const NOT_RELATED:int = 0;
        public static const CHILD:int = 1;
        public static const EQUAL:int = 2;
        public static const PARENT:int = 3;

        protected static var _resolver:IURIResolver = null;

        public function URI(_arg1:String=null):void{
            if (_arg1 == null){
                this.initialize();
            } else {
                this.constructURI(_arg1);
            };
        }
        protected function constructURI(_arg1:String):Boolean{
            if (!this.parseURI(_arg1)){
                this._valid = false;
            };
            return (this.isValid());
        }
        protected function initialize():void{
            this._valid = false;
            this._relative = false;
            this._scheme = UNKNOWN_SCHEME;
            this._authority = "";
            this._username = "";
            this._password = "";
            this._port = "";
            this._path = "";
            this._query = "";
            this._fragment = "";
            this._nonHierarchical = "";
        }
        protected function set hierState(_arg1:Boolean):void{
            if (_arg1){
                this._nonHierarchical = "";
                if ((((this._scheme == "")) || ((this._scheme == UNKNOWN_SCHEME)))){
                    this._relative = true;
                } else {
                    this._relative = false;
                };
                if ((((this._authority.length == 0)) && ((this._path.length == 0)))){
                    this._valid = false;
                } else {
                    this._valid = true;
                };
            } else {
                this._authority = "";
                this._username = "";
                this._password = "";
                this._port = "";
                this._path = "";
                this._relative = false;
                if ((((this._scheme == "")) || ((this._scheme == UNKNOWN_SCHEME)))){
                    this._valid = false;
                } else {
                    this._valid = true;
                };
            };
        }
        protected function get hierState():Boolean{
            return ((this._nonHierarchical.length == 0));
        }
        protected function validateURI():Boolean{
            if (this.isAbsolute()){
                if ((((this._scheme.length <= 1)) || ((this._scheme == UNKNOWN_SCHEME)))){
                    return (false);
                };
                if (this.verifyAlpha(this._scheme) == false){
                    return (false);
                };
            };
            if (this.hierState){
                if (this._path.search("\\") != -1){
                    return (false);
                };
                if ((((this.isRelative() == false)) && ((this._scheme == UNKNOWN_SCHEME)))){
                    return (false);
                };
            } else {
                if (this._nonHierarchical.search("\\") != -1){
                    return (false);
                };
            };
            return (true);
        }
        protected function parseURI(_arg1:String):Boolean{
            var _local3:int;
            var _local4:int;
            var _local2:String = _arg1;
            this.initialize();
            _local3 = _local2.indexOf("#");
            if (_local3 != -1){
                if (_local2.length > (_local3 + 1)){
                    this._fragment = _local2.substr((_local3 + 1), (_local2.length - (_local3 + 1)));
                };
                _local2 = _local2.substr(0, _local3);
            };
            _local3 = _local2.indexOf("?");
            if (_local3 != -1){
                if (_local2.length > (_local3 + 1)){
                    this._query = _local2.substr((_local3 + 1), (_local2.length - (_local3 + 1)));
                };
                _local2 = _local2.substr(0, _local3);
            };
            _local3 = _local2.search(":");
            _local4 = _local2.search("/");
            var _local5 = !((_local3 == -1));
            var _local6 = !((_local4 == -1));
            var _local7:Boolean = ((!(_local6)) || ((_local3 < _local4)));
            if (((_local5) && (_local7))){
                this._scheme = _local2.substr(0, _local3);
                this._scheme = this._scheme.toLowerCase();
                _local2 = _local2.substr((_local3 + 1));
                if (_local2.substr(0, 2) == "//"){
                    this._nonHierarchical = "";
                    _local2 = _local2.substr(2, (_local2.length - 2));
                } else {
                    this._nonHierarchical = _local2;
                    if ((this._valid = this.validateURI()) == false){
                        this.initialize();
                    };
                    return (this.isValid());
                };
            } else {
                this._scheme = "";
                this._relative = true;
                this._nonHierarchical = "";
            };
            if (this.isRelative()){
                this._authority = "";
                this._port = "";
                this._path = _local2;
            } else {
                if (_local2.substr(0, 2) == "//"){
                    while (_local2.charAt(0) == "/") {
                        _local2 = _local2.substr(1, (_local2.length - 1));
                    };
                };
                _local3 = _local2.search("/");
                if (_local3 == -1){
                    this._authority = _local2;
                    this._path = "";
                } else {
                    this._authority = _local2.substr(0, _local3);
                    this._path = _local2.substr(_local3, (_local2.length - _local3));
                };
                _local3 = this._authority.search("@");
                if (_local3 != -1){
                    this._username = this._authority.substr(0, _local3);
                    this._authority = this._authority.substr((_local3 + 1));
                    _local3 = this._username.search(":");
                    if (_local3 != -1){
                        this._password = this._username.substring((_local3 + 1), this._username.length);
                        this._username = this._username.substr(0, _local3);
                    } else {
                        this._password = "";
                    };
                } else {
                    this._username = "";
                    this._password = "";
                };
                _local3 = this._authority.search(":");
                if (_local3 != -1){
                    this._port = this._authority.substring((_local3 + 1), this._authority.length);
                    this._authority = this._authority.substr(0, _local3);
                } else {
                    this._port = "";
                };
                this._authority = this._authority.toLowerCase();
            };
            if ((this._valid = this.validateURI()) == false){
                this.initialize();
            };
            return (this.isValid());
        }
        public function copyURI(_arg1:URI):void{
            this._scheme = _arg1._scheme;
            this._authority = _arg1._authority;
            this._username = _arg1._username;
            this._password = _arg1._password;
            this._port = _arg1._port;
            this._path = _arg1._path;
            this._query = _arg1._query;
            this._fragment = _arg1._fragment;
            this._nonHierarchical = _arg1._nonHierarchical;
            this._valid = _arg1._valid;
            this._relative = _arg1._relative;
        }
        protected function verifyAlpha(_arg1:String):Boolean{
            var _local3:int;
            var _local2:RegExp = /[^a-z]/;
            _arg1 = _arg1.toLowerCase();
            _local3 = _arg1.search(_local2);
            if (_local3 == -1){
                return (true);
            };
            return (false);
        }
        public function isValid():Boolean{
            return (this._valid);
        }
        public function isAbsolute():Boolean{
            return (!(this._relative));
        }
        public function isRelative():Boolean{
            return (this._relative);
        }
        public function isDirectory():Boolean{
            if (this._path.length == 0){
                return (false);
            };
            return ((this._path.charAt((this.path.length - 1)) == "/"));
        }
        public function isHierarchical():Boolean{
            return (this.hierState);
        }
        public function get scheme():String{
            return (URI.unescapeChars(this._scheme));
        }
        public function set scheme(_arg1:String):void{
            var _local2:String = _arg1.toLowerCase();
            this._scheme = URI.fastEscapeChars(_local2, URI.URIschemeExcludedBitmap);
        }
        public function get authority():String{
            return (URI.unescapeChars(this._authority));
        }
        public function set authority(_arg1:String):void{
            _arg1 = _arg1.toLowerCase();
            this._authority = URI.fastEscapeChars(_arg1, URI.URIauthorityExcludedBitmap);
            this.hierState = true;
        }
        public function get username():String{
            return (URI.unescapeChars(this._username));
        }
        public function set username(_arg1:String):void{
            this._username = URI.fastEscapeChars(_arg1, URI.URIuserpassExcludedBitmap);
            this.hierState = true;
        }
        public function get password():String{
            return (URI.unescapeChars(this._password));
        }
        public function set password(_arg1:String):void{
            this._password = URI.fastEscapeChars(_arg1, URI.URIuserpassExcludedBitmap);
            this.hierState = true;
        }
        public function get port():String{
            return (URI.unescapeChars(this._port));
        }
        public function set port(_arg1:String):void{
            this._port = URI.escapeChars(_arg1);
            this.hierState = true;
        }
        public function get path():String{
            return (URI.unescapeChars(this._path));
        }
        public function set path(_arg1:String):void{
            this._path = URI.fastEscapeChars(_arg1, URI.URIpathExcludedBitmap);
            if (this._scheme == UNKNOWN_SCHEME){
                this._scheme = "";
            };
            this.hierState = true;
        }
        public function get query():String{
            return (URI.unescapeChars(this._query));
        }
        public function set query(_arg1:String):void{
            this._query = URI.fastEscapeChars(_arg1, URI.URIqueryExcludedBitmap);
        }
        public function get queryRaw():String{
            return (this._query);
        }
        public function set queryRaw(_arg1:String):void{
            this._query = _arg1;
        }
        public function get fragment():String{
            return (URI.unescapeChars(this._fragment));
        }
        public function set fragment(_arg1:String):void{
            this._fragment = URI.fastEscapeChars(_arg1, URIfragmentExcludedBitmap);
        }
        public function get nonHierarchical():String{
            return (URI.unescapeChars(this._nonHierarchical));
        }
        public function set nonHierarchical(_arg1:String):void{
            this._nonHierarchical = URI.fastEscapeChars(_arg1, URInonHierexcludedBitmap);
            this.hierState = false;
        }
        public function setParts(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:String):void{
            this.scheme = _arg1;
            this.authority = _arg2;
            this.port = _arg3;
            this.path = _arg4;
            this.query = _arg5;
            this.fragment = _arg6;
            this.hierState = true;
        }
        public function isOfType(_arg1:String):Boolean{
            _arg1 = _arg1.toLowerCase();
            return ((this._scheme == _arg1));
        }
        public function getQueryValue(_arg1:String):String{
            var _local2:Object;
            var _local3:String;
            var _local4:String;
            _local2 = this.getQueryByMap();
            for (_local3 in _local2) {
                if (_local3 == _arg1){
                    _local4 = _local2[_local3];
                    return (_local4);
                };
            };
            return (new String(""));
        }
        public function setQueryValue(_arg1:String, _arg2:String):void{
            var _local3:Object;
            _local3 = this.getQueryByMap();
            _local3[_arg1] = _arg2;
            this.setQueryByMap(_local3);
        }
        public function getQueryByMap():Object{
            var _local1:String;
            var _local2:String;
            var _local3:Array;
            var _local4:Array;
            var _local5:String;
            var _local6:String;
            var _local7:int;
            var _local8:Object = new Object();
            _local1 = this._query;
            _local3 = _local1.split("&");
            for each (_local2 in _local3) {
                if (_local2.length == 0){
                } else {
                    _local4 = _local2.split("=");
                    if (_local4.length > 0){
                        _local5 = _local4[0];
                    } else {
                        continue;
                    };
                    if (_local4.length > 1){
                        _local6 = _local4[1];
                    } else {
                        _local6 = "";
                    };
                    _local5 = queryPartUnescape(_local5);
                    _local6 = queryPartUnescape(_local6);
                    _local8[_local5] = _local6;
                };
            };
            return (_local8);
        }
        public function setQueryByMap(_arg1:Object):void{
            var _local2:String;
            var _local3:String;
            var _local4:String;
            var _local6:String;
            var _local7:String;
            var _local5 = "";
            for (_local2 in _arg1) {
                _local3 = _local2;
                _local4 = _arg1[_local2];
                if (_local4 == null){
                    _local4 = "";
                };
                _local3 = queryPartEscape(_local3);
                _local4 = queryPartEscape(_local4);
                _local6 = _local3;
                if (_local4.length > 0){
                    _local6 = (_local6 + "=");
                    _local6 = (_local6 + _local4);
                };
                if (_local5.length != 0){
                    _local5 = (_local5 + "&");
                };
                _local5 = (_local5 + _local6);
            };
            this._query = _local5;
        }
        public function toString():String{
            if (this == null){
                return ("");
            };
            return (this.toStringInternal(false));
        }
        public function toDisplayString():String{
            return (this.toStringInternal(true));
        }
        protected function toStringInternal(_arg1:Boolean):String{
            var _local2 = "";
            var _local3 = "";
            if (this.isHierarchical() == false){
                _local2 = (_local2 + (_arg1) ? this.scheme : this._scheme);
                _local2 = (_local2 + ":");
                _local2 = (_local2 + (_arg1) ? this.nonHierarchical : this._nonHierarchical);
            } else {
                if (this.isRelative() == false){
                    if (this._scheme.length != 0){
                        _local3 = (_arg1) ? this.scheme : this._scheme;
                        _local2 = (_local2 + (_local3 + ":"));
                    };
                    if (((!((this._authority.length == 0))) || (this.isOfType("file")))){
                        _local2 = (_local2 + "//");
                        if (this._username.length != 0){
                            _local3 = (_arg1) ? this.username : this._username;
                            _local2 = (_local2 + _local3);
                            if (this._password.length != 0){
                                _local3 = (_arg1) ? this.password : this._password;
                                _local2 = (_local2 + (":" + _local3));
                            };
                            _local2 = (_local2 + "@");
                        };
                        _local3 = (_arg1) ? this.authority : this._authority;
                        _local2 = (_local2 + _local3);
                        if (this.port.length != 0){
                            _local2 = (_local2 + (":" + this.port));
                        };
                    };
                };
                _local3 = (_arg1) ? this.path : this._path;
                _local2 = (_local2 + _local3);
            };
            if (this._query.length != 0){
                _local3 = (_arg1) ? this.query : this._query;
                _local2 = (_local2 + ("?" + _local3));
            };
            if (this.fragment.length != 0){
                _local3 = (_arg1) ? this.fragment : this._fragment;
                _local2 = (_local2 + ("#" + _local3));
            };
            return (_local2);
        }
        public function forceEscape():void{
            this.scheme = this.scheme;
            this.setQueryByMap(this.getQueryByMap());
            this.fragment = this.fragment;
            if (this.isHierarchical()){
                this.authority = this.authority;
                this.path = this.path;
                this.port = this.port;
                this.username = this.username;
                this.password = this.password;
            } else {
                this.nonHierarchical = this.nonHierarchical;
            };
        }
        public function isOfFileType(_arg1:String):Boolean{
            var _local2:String;
            var _local3:int;
            _local3 = _arg1.lastIndexOf(".");
            if (_local3 != -1){
                _arg1 = _arg1.substr((_local3 + 1));
            };
            _local2 = this.getExtension(true);
            if (_local2 == ""){
                return (false);
            };
            if (compareStr(_local2, _arg1, false) == 0){
                return (true);
            };
            return (false);
        }
        public function getExtension(_arg1:Boolean=false):String{
            var _local3:String;
            var _local4:int;
            var _local2:String = this.getFilename();
            if (_local2 == ""){
                return (String(""));
            };
            _local4 = _local2.lastIndexOf(".");
            if ((((_local4 == -1)) || ((_local4 == 0)))){
                return (String(""));
            };
            _local3 = _local2.substr(_local4);
            if (((_arg1) && ((_local3.charAt(0) == ".")))){
                _local3 = _local3.substr(1);
            };
            return (_local3);
        }
        public function getFilename(_arg1:Boolean=false):String{
            var _local3:String;
            var _local4:int;
            if (this.isDirectory()){
                return (String(""));
            };
            var _local2:String = this.path;
            _local4 = _local2.lastIndexOf("/");
            if (_local4 != -1){
                _local3 = _local2.substr((_local4 + 1));
            } else {
                _local3 = _local2;
            };
            if (_arg1){
                _local4 = _local3.lastIndexOf(".");
                if (_local4 != -1){
                    _local3 = _local3.substr(0, _local4);
                };
            };
            return (_local3);
        }
        public function getDefaultPort():String{
            if (this._scheme == "http"){
                return (String("80"));
            };
            if (this._scheme == "ftp"){
                return (String("21"));
            };
            if (this._scheme == "file"){
                return (String(""));
            };
            if (this._scheme == "sftp"){
                return (String("22"));
            };
            return (String(""));
        }
        public function getRelation(_arg1:URI, _arg2:Boolean=true):int{
            var _local9:Array;
            var _local10:Array;
            var _local11:String;
            var _local12:String;
            var _local13:int;
            var _local3:URI = URI.resolve(this);
            var _local4:URI = URI.resolve(_arg1);
            if (((_local3.isRelative()) || (_local4.isRelative()))){
                return (URI.NOT_RELATED);
            };
            if ((((_local3.isHierarchical() == false)) || ((_local4.isHierarchical() == false)))){
                if ((((((_local3.isHierarchical() == false)) && ((_local4.isHierarchical() == true)))) || ((((_local3.isHierarchical() == true)) && ((_local4.isHierarchical() == false)))))){
                    return (URI.NOT_RELATED);
                };
                if (_local3.scheme != _local4.scheme){
                    return (URI.NOT_RELATED);
                };
                if (_local3.nonHierarchical != _local4.nonHierarchical){
                    return (URI.NOT_RELATED);
                };
                return (URI.EQUAL);
            };
            if (_local3.scheme != _local4.scheme){
                return (URI.NOT_RELATED);
            };
            if (_local3.authority != _local4.authority){
                return (URI.NOT_RELATED);
            };
            var _local5:String = _local3.port;
            var _local6:String = _local4.port;
            if (_local5 == ""){
                _local5 = _local3.getDefaultPort();
            };
            if (_local6 == ""){
                _local6 = _local4.getDefaultPort();
            };
            if (_local5 != _local6){
                return (URI.NOT_RELATED);
            };
            if (compareStr(_local3.path, _local4.path, _arg2)){
                return (URI.EQUAL);
            };
            var _local7:String = _local3.path;
            var _local8:String = _local4.path;
            if ((((((_local7 == "/")) || ((_local8 == "/")))) && ((((_local7 == "")) || ((_local8 == "")))))){
                return (URI.EQUAL);
            };
            _local9 = _local7.split("/");
            _local10 = _local8.split("/");
            if (_local9.length > _local10.length){
                _local12 = _local10[(_local10.length - 1)];
                if (_local12.length > 0){
                    return (URI.NOT_RELATED);
                };
                _local10.pop();
                _local13 = 0;
                while (_local13 < _local10.length) {
                    _local11 = _local9[_local13];
                    _local12 = _local10[_local13];
                    if (compareStr(_local11, _local12, _arg2) == false){
                        return (URI.NOT_RELATED);
                    };
                    _local13++;
                };
                return (URI.CHILD);
                //unresolved jump
            };
            if (_local9.length < _local10.length){
                _local11 = _local9[(_local9.length - 1)];
                if (_local11.length > 0){
                    return (URI.NOT_RELATED);
                };
                _local9.pop();
                _local13 = 0;
                while (_local13 < _local9.length) {
                    _local11 = _local9[_local13];
                    _local12 = _local10[_local13];
                    if (compareStr(_local11, _local12, _arg2) == false){
                        return (URI.NOT_RELATED);
                    };
                    _local13++;
                };
                return (URI.PARENT);
                //unresolved jump
            };
            return (URI.NOT_RELATED);
        }
        public function getCommonParent(_arg1:URI, _arg2:Boolean=true):URI{
            var _local6:String;
            var _local7:String;
            var _local3:URI = URI.resolve(this);
            var _local4:URI = URI.resolve(_arg1);
            if (((((((!(_local3.isAbsolute())) || (!(_local4.isAbsolute())))) || ((_local3.isHierarchical() == false)))) || ((_local4.isHierarchical() == false)))){
                return (null);
            };
            var _local5:int = _local3.getRelation(_local4);
            if (_local5 == URI.NOT_RELATED){
                return (null);
            };
            _local3.chdir(".");
            _local4.chdir(".");
            do  {
                _local5 = _local3.getRelation(_local4, _arg2);
            } while (!((((_local5 == URI.EQUAL)) || ((_local5 == URI.PARENT)))));
            return (_local3);
        }
        public function chdir(_arg1:String, _arg2:Boolean=false):Boolean{
            var _local3:URI;
            var _local5:String;
            var _local6:String;
            var _local7:Array;
            var _local8:Array;
            var _local14:String;
            var _local15:int;
            var _local17:String;
            var _local4:String = _arg1;
            if (_arg2){
                _local4 = URI.escapeChars(_arg1);
            };
            if (_local4 == ""){
                return (true);
            };
            if (_local4.substr(0, 2) == "//"){
                _local17 = ((this.scheme + ":") + _local4);
                return (this.constructURI(_local17));
            };
            if (_local4.charAt(0) == "?"){
                _local4 = ("./" + _local4);
            };
            _local3 = new URI(_local4);
            if (((_local3.isAbsolute()) || ((_local3.isHierarchical() == false)))){
                this.copyURI(_local3);
                return (true);
            };
            var _local9:Boolean;
            var _local10:Boolean;
            var _local11:Boolean;
            var _local12:Boolean;
            var _local13:Boolean;
            _local5 = this.path;
            _local6 = _local3.path;
            if (_local5.length > 0){
                _local7 = _local5.split("/");
            } else {
                _local7 = new Array();
            };
            if (_local6.length > 0){
                _local8 = _local6.split("/");
            } else {
                _local8 = new Array();
            };
            if ((((_local7.length > 0)) && ((_local7[0] == "")))){
                _local11 = true;
                _local7.shift();
            };
            if ((((_local7.length > 0)) && ((_local7[(_local7.length - 1)] == "")))){
                _local9 = true;
                _local7.pop();
            };
            if ((((_local8.length > 0)) && ((_local8[0] == "")))){
                _local12 = true;
                _local8.shift();
            };
            if ((((_local8.length > 0)) && ((_local8[(_local8.length - 1)] == "")))){
                _local10 = true;
                _local8.pop();
            };
            if (_local12){
                this.path = _local3.path;
                this.queryRaw = _local3.queryRaw;
                this.fragment = _local3.fragment;
                return (true);
            };
            if ((((_local8.length == 0)) && ((_local3.query == "")))){
                this.fragment = _local3.fragment;
                return (true);
            };
            if ((((_local9 == false)) && ((_local7.length > 0)))){
                _local7.pop();
            };
            this.queryRaw = _local3.queryRaw;
            this.fragment = _local3.fragment;
            _local7 = _local7.concat(_local8);
            _local15 = 0;
            while (_local15 < _local7.length) {
                _local14 = _local7[_local15];
                _local13 = false;
                if (_local14 == "."){
                    _local7.splice(_local15, 1);
                    _local15--;
                    _local13 = true;
                } else {
                    if (_local14 == ".."){
                        if (_local15 >= 1){
                            if (_local7[(_local15 - 1)] == ".."){
                            } else {
                                _local7.splice((_local15 - 1), 2);
                                _local15 = (_local15 - 2);
                            };
                        } else {
                            if (this.isRelative()){
                            } else {
                                _local7.splice(_local15, 1);
                                _local15--;
                            };
                        };
                        _local13 = true;
                    };
                };
                _local15++;
            };
            var _local16 = "";
            _local10 = ((_local10) || (_local13));
            _local16 = this.joinPath(_local7, _local11, _local10);
            this.path = _local16;
            return (true);
        }
        protected function joinPath(_arg1:Array, _arg2:Boolean, _arg3:Boolean):String{
            var _local5:int;
            var _local4 = "";
            _local5 = 0;
            while (_local5 < _arg1.length) {
                if (_local4.length > 0){
                    _local4 = (_local4 + "/");
                };
                _local4 = (_local4 + _arg1[_local5]);
                _local5++;
            };
            if (((_arg3) && ((_local4.length > 0)))){
                _local4 = (_local4 + "/");
            };
            if (_arg2){
                _local4 = ("/" + _local4);
            };
            return (_local4);
        }
        public function makeAbsoluteURI(_arg1:URI):Boolean{
            if (((this.isAbsolute()) || (_arg1.isRelative()))){
                return (false);
            };
            var _local2:URI = new URI();
            _local2.copyURI(_arg1);
            if (_local2.chdir(this.toString()) == false){
                return (false);
            };
            this.copyURI(_local2);
            return (true);
        }
        public function makeRelativeURI(_arg1:URI, _arg2:Boolean=true):Boolean{
            var _local4:Array;
            var _local5:Array;
            var _local7:String;
            var _local8:String;
            var _local9:String;
            var _local13:int;
            var _local3:URI = new URI();
            _local3.copyURI(_arg1);
            var _local6:Array = new Array();
            var _local10:String = this.path;
            var _local11:String = this.queryRaw;
            var _local12:String = this.fragment;
            var _local14:Boolean;
            var _local15:Boolean;
            if (this.isRelative()){
                return (true);
            };
            if (_local3.isRelative()){
                return (false);
            };
            if ((((this.isOfType(_arg1.scheme) == false)) || (!((this.authority == _arg1.authority))))){
                return (false);
            };
            _local15 = this.isDirectory();
            _local3.chdir(".");
            _local4 = _local10.split("/");
            _local5 = _local3.path.split("/");
            if ((((_local4.length > 0)) && ((_local4[0] == "")))){
                _local4.shift();
            };
            if ((((_local4.length > 0)) && ((_local4[(_local4.length - 1)] == "")))){
                _local15 = true;
                _local4.pop();
            };
            if ((((_local5.length > 0)) && ((_local5[0] == "")))){
                _local5.shift();
            };
            if ((((_local5.length > 0)) && ((_local5[(_local5.length - 1)] == "")))){
                _local5.pop();
            };
            while (_local5.length > 0) {
                if (_local4.length == 0){
                    break;
                };
                _local7 = _local4[0];
                _local8 = _local5[0];
                if (compareStr(_local7, _local8, _arg2)){
                    _local4.shift();
                    _local5.shift();
                } else {
                    break;
                };
            };
            var _local16 = "..";
            _local13 = 0;
            while (_local13 < _local5.length) {
                _local6.push(_local16);
                _local13++;
            };
            _local6 = _local6.concat(_local4);
            _local9 = this.joinPath(_local6, false, _local15);
            if (_local9.length == 0){
                _local9 = "./";
            };
            this.setParts("", "", "", _local9, _local11, _local12);
            return (true);
        }
        public function unknownToURI(_arg1:String, _arg2:String="http"):Boolean{
            var _local3:String;
            var _local5:String;
            if (_arg1.length == 0){
                this.initialize();
                return (false);
            };
            _arg1 = _arg1.replace(/\\/g, "/");
            if (_arg1.length >= 2){
                _local3 = _arg1.substr(0, 2);
                if (_local3 == "//"){
                    _arg1 = ((_arg2 + ":") + _arg1);
                };
            };
            if (_arg1.length >= 3){
                _local3 = _arg1.substr(0, 3);
                if (_local3 == "://"){
                    _arg1 = (_arg2 + _arg1);
                };
            };
            var _local4:URI = new URI(_arg1);
            if (_local4.isHierarchical() == false){
                if (_local4.scheme == UNKNOWN_SCHEME){
                    this.initialize();
                    return (false);
                };
                this.copyURI(_local4);
                this.forceEscape();
                return (true);
            } else {
                if (((!((_local4.scheme == UNKNOWN_SCHEME))) && ((_local4.scheme.length > 0)))){
                    if ((((_local4.authority.length > 0)) || ((_local4.scheme == "file")))){
                        this.copyURI(_local4);
                        this.forceEscape();
                        return (true);
                    };
                    if ((((_local4.authority.length == 0)) && ((_local4.path.length == 0)))){
                        this.setParts(_local4.scheme, "", "", "", "", "");
                        return (false);
                    };
                } else {
                    _local5 = _local4.path;
                    if ((((((((_local5 == "..")) || ((_local5 == ".")))) || ((((_local5.length >= 3)) && ((_local5.substr(0, 3) == "../")))))) || ((((_local5.length >= 2)) && ((_local5.substr(0, 2) == "./")))))){
                        this.copyURI(_local4);
                        this.forceEscape();
                        return (true);
                    };
                };
            };
            _local4 = new URI(((_arg2 + "://") + _arg1));
            if ((((_local4.scheme.length > 0)) && ((_local4.authority.length > 0)))){
                this.copyURI(_local4);
                this.forceEscape();
                return (true);
            };
            this.initialize();
            return (false);
        }

        public static function escapeChars(_arg1:String):String{
            return (fastEscapeChars(_arg1, URI.URIbaselineExcludedBitmap));
        }
        public static function unescapeChars(_arg1:String):String{
            var _local2:String;
            _local2 = decodeURIComponent(_arg1);
            return (_local2);
        }
        public static function fastEscapeChars(_arg1:String, _arg2:URIEncodingBitmap):String{
            var _local4:String;
            var _local5:int;
            var _local6:int;
            var _local3 = "";
            _local6 = 0;
            while (_local6 < _arg1.length) {
                _local4 = _arg1.charAt(_local6);
                _local5 = _arg2.ShouldEscape(_local4);
                if (_local5){
                    _local4 = _local5.toString(16);
                    if (_local4.length == 1){
                        _local4 = ("0" + _local4);
                    };
                    _local4 = ("%" + _local4);
                    _local4 = _local4.toUpperCase();
                };
                _local3 = (_local3 + _local4);
                _local6++;
            };
            return (_local3);
        }
        public static function queryPartEscape(_arg1:String):String{
            var _local2:String = _arg1;
            _local2 = URI.fastEscapeChars(_arg1, URI.URIqueryPartExcludedBitmap);
            return (_local2);
        }
        public static function queryPartUnescape(_arg1:String):String{
            var _local2:String = _arg1;
            _local2 = unescapeChars(_local2);
            return (_local2);
        }
        protected static function compareStr(_arg1:String, _arg2:String, _arg3:Boolean=true):Boolean{
            if (_arg3 == false){
                _arg1 = _arg1.toLowerCase();
                _arg2 = _arg2.toLowerCase();
            };
            return ((_arg1 == _arg2));
        }
        protected static function resolve(_arg1:URI):URI{
            var _local2:URI = new (URI);
            _local2.copyURI(_arg1);
            if (_resolver != null){
                return (_resolver.resolve(_local2));
            };
            return (_local2);
        }
        public static function set resolver(_arg1:IURIResolver):void{
            _resolver = _arg1;
        }
        public static function get resolver():IURIResolver{
            return (_resolver);
        }

    }
}//package com.adobe.net 
